package com.dt.dubai.mber.controller;

import com.dt.dubai.mber.entity.MberCustomerLoginEntity;
import com.dt.dubai.mber.controller.innate.MberCustomerLoginInnateAbs;
import com.dt.dubai.core.comm.*;
import com.dt.dubai.core.utile.DateTools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;
import java.util.Map;

/*
* 顾客登录表
*/

@Controller
@RequestMapping(value = "/mber/mberCustomerLogin")
public class MberCustomerLoginController extends MberCustomerLoginInnateAbs {

    /*innateServiceStart*/
    @Override
    protected void userSavEntity(MberCustomerLoginEntity inEntity, final Long userId) {
        inEntity.setDelSign(false);
    }

    @Override
    protected void userModEntity(MberCustomerLoginEntity inEntity, final Long userId) {
    }

    @Override
    protected void userDelByKey(List<Long> recordIds, final Long userId) {
    }

    @Override
    protected void userQueByKey(Long recordId, Map<String, Object> map, final Long userId) {
        if (null != map && map.size() > 0) {
            map.put("createTxStamp", DateTools.dateFormat((Date) map.get("createTxStamp"), DateTools.DATE_FORMAT_YMD));
            map.remove("delSign");
            map.remove("lastupTxStamp");
        }
    }

    @Override
    protected void userQuePageList(PageParameterData queryCondition, List<PageCondition> joinCondition, List<Map<String, Object>> resultMap, final Long userId) {
        for (Map<String, Object> map : resultMap) {
            map.put("createTxStamp", DateTools.dateFormat((Date) map.get("createTxStamp"), DateTools.DATE_FORMAT_YMD));
            Short sex = null == map.get("sex") ? -1 :  (Short) map.get("sex");
            switch (sex) {
                case 1:
                    map.put("sex", sex);
                    map.put("sexStr", "女性");
                    break;
                case 2:
                    map.put("sex", sex);
                    map.put("sexStr", "男性");
                    break;
                case 3:
                    map.put("sex", sex);
                    map.put("sexStr", "未知");
                    break;
                default:
                    map.put("sex", -1);
                    map.put("sexStr", "未知");
            }
            Short loginStatus = null == map.get("loginStatus") ? -1 :  (Short) map.get("loginStatus");
            switch (loginStatus) {
                case 0:
                    map.put("loginStatus", loginStatus);
                    map.put("loginStatusStr", "正常");
                    break;
                case 1:
                    map.put("loginStatus", loginStatus);
                    map.put("loginStatusStr", "锁定");
                    break;
                case 2:
                    map.put("loginStatus", loginStatus);
                    map.put("loginStatusStr", "禁用");
                    break;
                default:
                    map.put("loginStatus", -1);
                    map.put("loginStatusStr", "未知");
            }
            Boolean realNameStatus = null == map.get("realNameStatus") ? false : (Boolean) map.get("realNameStatus");
            if (realNameStatus) {
                map.put("realNameStatus", realNameStatus);
                map.put("realNameStatusStr", "已认证");
            } else {
                map.put("realNameStatus", realNameStatus);
                map.put("realNameStatusStr", "未认证");
            }
            if (null != map.get("loginTime"))
                map.put("loginTime", DateTools.dateFormat((Date) map.get("loginTime"), DateTools.DATE_FORMAT_YMD));
            map.remove("delSign");
            map.remove("lastupTxStamp");
        }
    }

    /*innateServiceEnd*/
    /*以上内容请误删除或是移动，系统升级使用，用户代码请写入下方*/
}